package owg.util.opengl;

import com.jogamp.opengl.GL;
/**Provides an interface similar to OpenGL1's immediate mode.<br/>
 * This exists solely for the programmer's convenience and should only be used for debugging or 
 * low-poly models where performance is not an issue. <br>
 * <br>
 * Note that this can be used to build a display list equivalent by setting retainModel to true and keeping the GLRenderable. This use would be fairly efficient.*/
public interface ImmediateModeWrapper<GLT extends GL>
	{
	public GLRenderable glBegin(boolean retainModel, int faceMode, 
			int nVertexComps, boolean useNormal, int nColorComps, int nTexCoords);
	
	public void glNormal3f(float x, float y, float z);
	
	default void glNormal3fv(float[] v, int offset)
	{
	    glNormal3f(v[offset], v[offset+1], v[offset+2]);
	}
	default void glNormal3d(double x, double y, double z)
	{
	    glNormal3f((float)x, (float)y, (float)z);
	}
	default void glNormal3dv(double[] v, int offset)
	{
	    glNormal3d(v[offset], v[offset+1], v[offset+2]);
	}
	
	public void glColor4f(float r, float g, float b, float a);

	default void glColor4fv(float[] v, int offset)
	{
	    glColor4f(v[offset], v[offset+1], v[offset+2], v[offset+3]);
	}
	default void glColor4d(double r, double g, double b, double a)
	{
	    glColor4f((float)r, (float)g, (float)b, (float)a);
	}
	default void glColor4dv(double[] v, int offset)
	{
	    glColor4d(v[offset], v[offset+1], v[offset+2], v[offset+3]);
	}
	default void glColor3f(float r, float g, float b)
	{
	    glColor4f(r, g, b, 1);
	}
	default void glColor3fv(float[] v, int offset)
	{
	    glColor3f(v[offset], v[offset+1], v[offset+2]);
	}
	default void glColor3d(double r, double g, double b)
	{
	    glColor3f((float)r, (float)g, (float)b);
	}
	default void glColor3dv(double[] v, int offset)
	{
	    glColor3d(v[offset], v[offset+1], v[offset+2]);
	}
	default void glColor(ColorF color)
	{
	    glColor4f(color.getRed(), color.getGreen(), color.getBlue(), color.getAlpha());
	}
	
	public void glTexCoord4f(float s, float t, float r, float q);
	
	default void glTexCoord4fv(float[] v, int offset)
	{
	    glTexCoord4f(v[offset], v[offset+1], v[offset+2], v[offset+3]);
	}
	default void glTexCoord4d(double s, double t, double r, double q)
	{
	    glTexCoord4f((float)s, (float)t, (float)r, (float)q);
	}
	default void glTexCoord4dv(double[] v, int offset)
	{
	    glTexCoord4d(v[offset], v[offset+1], v[offset+2], v[offset+3]);
	}

	default void glTexCoord3f(float s, float t, float r)
	{
	    glTexCoord4f(s, t, r, 0);
	}
	default void glTexCoord3fv(float[] v, int offset)
	{
	    glTexCoord3f(v[offset], v[offset+1], v[offset+2]);
	}
	default void glTexCoord3d(double s, double t, double r)
	{
	    glTexCoord3f((float)s, (float)t, (float)r);
	}
	default void glTexCoord3dv(double[] v, int offset)
	{
	    glTexCoord3d(v[offset], v[offset+1], v[offset+2]);
	}
	default void glTexCoord2f(float s, float t)
	{
	    glTexCoord3f(s, t, 0);
	}
	default void glTexCoord2fv(float[] v, int offset)
	{
	    glTexCoord2f(v[offset], v[offset+1]);
	}
	default void glTexCoord2d(double s, double t)
	{
	    glTexCoord2f((float)s, (float)t);
	}
	default void glTexCoord2dv(double[] v, int offset)
	{
	    glTexCoord2d(v[offset], v[offset+1]);
	}
	
	public void glVertex3f(float x, float y, float z);
	
	default void glVertex3fv(float[] v, int offset)
	{
	    glVertex3f(v[offset], v[offset+1], v[offset+2]);
	}
	default void glVertex3d(double x, double y, double z)
	{
	    glVertex3f((float)x, (float)y, (float)z);
	}
	default void glVertex3dv(double[] v, int offset)
	{
	    glVertex3d(v[offset], v[offset+1], v[offset+2]);
	}
	default void glVertex2f(float x, float y)
	{
	    glVertex3f(x, y, 0);
	}
	default void glVertex2fv(float[] v, int offset)
	{
	    glVertex2f(v[offset], v[offset+1]);
	}
	default void glVertex2d(double x, double y)
	{
	    glVertex2f((float)x, (float)y);
	}
	default void glVertex2dv(double[] v, int offset)
	{
	    glVertex2d(v[offset], v[offset+1]);
	}
	/**The the primitive rendering sequence. If the sequence was started without retainModel set to true, then the model will be immediately rendered and disposed.<br/>
	 * It is illegal to call this method prior to 
	 * {@link #glBegin(Primitive, boolean, boolean, boolean, boolean, boolean)},
	 * or to call this method multiple times in succession without starting a new sequence between.*/
	public void glEnd();
	}
